package com.chooongg.simple

import android.os.Bundle
import com.chooongg.activity.BoxBindingActivity
import com.chooongg.adapter.BoxAdapter
import com.chooongg.adapter.listener.*
import com.chooongg.adapter.viewHolder.BoxViewHolder
import com.chooongg.ext.doOnClick
import com.chooongg.simple.databinding.ActivityMainBinding
import com.google.android.material.bottomappbar.BottomAppBar

class MainActivity : BoxBindingActivity<ActivityMainBinding>() {

    override fun isShowToolbarNavigationIcon() = false

    override fun snackBarAnchorView() = binding.bottomAppBar

    private val adapter = Adapter()

    override fun initConfig(savedInstanceState: Bundle?) {
        binding.confirmButton.doOnClick {
            if (binding.fab.isShown) {
                binding.fab.hide()
            } else {
                binding.fab.show()
            }
        }
        binding.confirmButton2.doOnClick {
            if (binding.bottomAppBar.fabAlignmentMode == BottomAppBar.FAB_ALIGNMENT_MODE_CENTER) {
                binding.bottomAppBar.fabAlignmentMode = BottomAppBar.FAB_ALIGNMENT_MODE_END
            } else {
                binding.bottomAppBar.fabAlignmentMode = BottomAppBar.FAB_ALIGNMENT_MODE_CENTER
            }
        }
    }

    override fun initContent() {
    }

    private var firstTime: Long = 0
    override fun onBackPressed() {
        val secondTime = System.currentTimeMillis()
        if (secondTime - firstTime > 2000) {
            showSnackBar("再按一次退出程序")
            firstTime = secondTime
        } else {
            super.onBackPressed()
        }
    }

    private class Adapter : BoxAdapter<Any, BoxViewHolder>() {

        override fun getItemViewType(position: Int): Int {
            return super.getItemViewType(position)
        }

        override fun convert(holder: BoxViewHolder, item: Any) {
            TODO("Not yet implemented")
        }

        override fun onBindViewHolder(holder: BoxViewHolder, position: Int) {
            TODO("Not yet implemented")
        }

        override fun setOnItemClickListener(listener: OnItemClickListener?) {
            TODO("Not yet implemented")
        }

        override fun setOnItemLongClickListener(listener: OnItemLongClickListener?) {
            TODO("Not yet implemented")
        }

        override fun setOnItemChildClickListener(listener: OnItemChildClickListener?) {
            TODO("Not yet implemented")
        }

        override fun setOnItemChildLongClickListener(listener: OnItemChildLongClickListener?) {
            TODO("Not yet implemented")
        }

        override fun setGridSpanSizeLookup(spanSizeLookup: GridSpanSizeLookup?) {
            TODO("Not yet implemented")
        }

    }
}